package com.leetcode.LeetCode精选TOP面试题;

/**
 * @author 覃国强
 * @date 2022-05-27 17:31
 */
public class 题库_0070_爬楼梯 {

  static
  class Solution {
    public int climbStairs(int n) {
      if (n <= 3) {
        return n;
      }
      int pre = 2;
      int cur = 3;
      int answer = 0;
      for (int i = 4; i <= n; ++i) {
        answer = pre + cur;
        pre = cur;
        cur = answer;
      }
      return answer;
    }
  }

}
